package com.example.jichu_1;

import android.content.Intent;
import android.os.Bundle;
import android.view.LayoutInflater;
import android.view.View;
import android.widget.Button;

import androidx.appcompat.app.AppCompatActivity;
import androidx.viewpager.widget.ViewPager;

import java.util.ArrayList;

public class Main2Activity extends AppCompatActivity {

    private ViewPager mVp;
    private VpAdapter vpAdapter;
    private Button btn;

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_main2);
        initView();
    }

    private void initView() {
        mVp = (ViewPager) findViewById(R.id.vp);
        ArrayList<View> list = new ArrayList<>();
        View v1 = LayoutInflater.from(this).inflate(R.layout.layout_vp1, null);
        View v2 = LayoutInflater.from(this).inflate(R.layout.layout_vp2, null);
        View v3 = LayoutInflater.from(this).inflate(R.layout.layout_vp3, null);
        btn = v3.findViewById(R.id.btn);
        btn.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View view) {
                startActivity(new Intent(Main2Activity.this,HomeActivity.class));
            }
        });
        list.add(v1);
        list.add(v2);
        list.add(v3);

        vpAdapter = new VpAdapter(this, list);
        mVp.setAdapter(vpAdapter);

    }
}
